﻿using AutoMapper;
using MediatR;
using S.PurchaseAndSales.Api.Application.Command.SheepSaleCommand;
using S.PurchaseAndSales.Domain.Model;
using S.PurchaseAndSales.Infrastructure.Interface.SalesForm;

namespace S.PurchaseAndSales.Api.Application.CommandHandlers.SheepSaleHandler
{
    public class SaleSheepUpdateCheckStateCommandHandler : IRequestHandler<SaleSheepUpdateCheckStateCommand, bool>
    {
        private readonly ISheepSaleRepository sheepSaleRepository;
        private readonly IMapper mapper;

        public SaleSheepUpdateCheckStateCommandHandler(ISheepSaleRepository sheepSaleRepository,IMapper mapper)
        {
            this.sheepSaleRepository = sheepSaleRepository;
            this.mapper = mapper;
        }
        /// <summary>
        /// 修改状态（审计状态、审计时间）
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        public Task<bool> Handle(SaleSheepUpdateCheckStateCommand request, CancellationToken cancellationToken)
        {
   
            SheepSaleModel sheepSaleModel = mapper.Map<SheepSaleModel>(request);
            return sheepSaleRepository.UpdateAsync(sheepSaleModel);
        }

       
    }
}
